<!--勾选-->
<template>
    <el-checkbox-group v-model="inputvalue" @change="returnBackFn">
        <!-- <el-checkbox :label="backTitle(list['title_'+lang])"></el-checkbox> -->
        <el-checkbox @click.native.stop="agreementShow($event)">
            <div v-html="backTitle(list['title_'+lang])"></div>
        </el-checkbox>
    </el-checkbox-group>
</template>
<script>
    import {backTitle} from "@/common/common";
    export default {
        components: {backTitle},
        props: ["list","lang",'value','isnone'],
        data() {
            return{
                inputvalue:false,
                backTitle:backTitle,
            }
        },
        mounted(){
            this.changeRules()
        },
        methods:{
            returnBackFn(){
                this.$emit('input',this.inputvalue)
            },
            changeRules(){
                var arr = [];
                if(this.list.is_require==1){
                    arr.push({ required: true,validator: this.checkSwitch})
                }
                this.$emit('changeRules',this.list.name,arr,this.isnone)
            },
            //自定义 判断是否勾选
            checkSwitch(rule, value, callback){
                //console.log(rule,value,11111)
                if(!value){
                    return callback(new Error(this.$t('m.Pleasecheck')));
                }else{
                    callback();
                }
            },
            agreementShow(event){
                if($(event.target)[0].localName == 'span'){
                    if($(event.target).hasClass('isClick')){
                        this.$emit('openClick','isStatementinfo')
                    }
                }else{
                    if($(event.target).find('.blueColor').hasClass('isClick')){
                        this.$emit('openClick','isStatementinfo')
                    }
                }
                
            }
        },
        watch:{
            value:{
                handler(val,old){
                    console.log(val,'111111')
                    if(val != undefined){
                        this.inputvalue = val == true?true:false;
                    }
                },
                immediate:true,
                deep:true,
            }
        }
    }
</script>